package com.dnzx.base;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;

public class ApiSecurityFilter implements Filter {
	/**
	 * 是否明文
	 */
	private Boolean clearText;

	@Override
	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
	    filterChain.doFilter(clearText?servletRequest:new ApiRequestWarpper(servletRequest), servletResponse);
	}

	@Override
	public void init(FilterConfig filterConfig){
	    this.clearText=Boolean.getBoolean(filterConfig.getInitParameter("clearText"));
    }

	@Override
	public void destroy() {}
}
